package com.zjkj.mp.dao.message.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import com.zjkj.mp.dao.DaoBase;
import com.zjkj.mp.dao.message.SendInfoDao;
import com.zjkj.mp.utils.PaginatedResult;
import com.zjkj.mp.vo.message.Message;

@Repository
public class SendInfoDaoImpl extends DaoBase implements SendInfoDao {

	@SuppressWarnings("unchecked")
	public List<Message> getMessageList(int tdId) {
		List<Message> list = getSqlMapClient().queryForList("get.messageList", tdId);
		return list;
	}

	public int delMessage(String fsId) {
		int num = getSqlMapClient().delete("del.delMessage", fsId);
		return num;
	}

	@SuppressWarnings("unchecked")
	public List<Message> getMessageList() {
		List<Message> list = getSqlMapClient().queryForList("get.messageAllList");
		return list;
	}
	
	@SuppressWarnings("unchecked")
	public PaginatedResult getMessagePageList(int nowPage, int maxRow, Map<String, Object> map) {
		if(map == null) 
			map= new HashMap<String, Object>();
		
		PaginatedResult result = new PaginatedResult(nowPage, maxRow);
		List<Map<String, Object>> message =  this.getSqlMapClient().queryForList("get.messagePageList", map, (nowPage-1)*maxRow, maxRow);
		result.setResult(message);
 
		int count = ((Integer)this.getSqlMapClient().queryForObject("get.messagePageListCount",map)).intValue();
		result.setTotalSize(count);
		
		return result;
	}

	@Override
	public int delMessageMx(String fsId) {
		int num = getSqlMapClient().delete("del.delMessageMx", fsId);
		return num;
	}
	
	@SuppressWarnings("unchecked")
	public PaginatedResult getMessageMxPageList(int nowPage, int maxRow, Map<String, Object> map) {
		if(map == null) 
			map= new HashMap<String, Object>();
		
		PaginatedResult result = new PaginatedResult(nowPage, maxRow);
		List<Map<String, Object>> message =  this.getSqlMapClient().queryForList("get.messageMxPageList", map, (nowPage-1)*maxRow, maxRow);
		result.setResult(message);
 
		int count = ((Integer)this.getSqlMapClient().queryForObject("get.messageMxPageListCount",map)).intValue();
		result.setTotalSize(count);
		
		return result;
	}

}
